package com.leruan.aasimp.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Expression;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.leruan.aasimp.dao.CarPartsImageDao;
import com.leruan.aasimp.entity.CarPartsImage;

public class CarPartsImageDaoImpl extends HibernateDaoSupport implements CarPartsImageDao{

	public void addPartsImage(CarPartsImage partsImage) {
		Session session = this.getSession();
		session.save(partsImage);
	}

	public CarPartsImage getImgByID(String title) {
		Session session = this.getSession();
		Criteria cri = session.createCriteria(CarPartsImage.class);
		Criterion  c1 = Expression.eq("partsId", title);
		cri.add(c1);
		CarPartsImage result = (CarPartsImage) cri.uniqueResult();
		return result;
	}

}
